extends Node
 
#声明一个变量
@export var mob_scene: PackedScene
@export var zd_scene: PackedScene
#分和时间
var score


func main_sudi(body: Node2D) -> void:
	print("main_索敌")
 

func _ready() -> void:
	print("启动")
	new_game()

func new_game():
	print("开始游戏")
	score = 0
	$StartTimer.start()
	$Player.start($StartPosition.position)
	$MobTimer.start()


func geme_over():
	print("游戏结束")
	$StartTimer.stop()
	$MobTimer.stop()

	
#开始计时器
func _on_start_timer_timeout() -> void:
	score += 1



func _on_mob_timer_timeout() -> void:
		#zd.position = $Player.position
	##方向
	var zd = zd_scene.instantiate()
	print("发射啊")
	zd.position = $Player.position
	zd.addFX(PI)
	add_child(zd) 
	#print("创建敌人") 
	#创建敌人
	# Create a new instance of the Mob scene.
	#var mob = mob_scene.instantiate()
#
	## Choose a random location on Path2D.
	#var mob_spawn_location = $mobpath/mobSpawnLocation
	#mob_spawn_location.progress_ratio = randf()
#
	## Set the mob's position to the random location.
	#mob.position = mob_spawn_location.position
#
	## Set the mob's direction perpendicular to the path direction.
	#var direction = mob_spawn_location.rotation + PI / 2
#
	## Add some randomness to the direction.
	#direction += randf_range(-PI / 4, PI / 4)
	#mob.rotation = direction
#
	## Choose the velocity for the mob.
	#var velocity = Vector2(randf_range(150.0, 250.0), 0.0)
	#mob.linear_velocity = velocity.rotated(direction)
#
	## Spawn the mob by adding it to the Main scene.
	#add_child(mob)
	


func _on_player_dr_jd(JD: float) -> void:
	#发射子弹
	print("创建子弹")
	#var zd = zd_scene.instantiate()
	##起点
	#zd.position = $Player.position
	##方向
	#zd.rotation_degrees = JD 
	#zd.addFX(JD)
	##var velocity = Vector2(randf_range(1500.0, 2500.0), 0.0)
	##zd.linear_velocity = velocity.rotated(direction)
	#add_child(zd)
	
